<template>
  <div>
    <x-header>帖子详情</x-header>
    <flexbox orient="vertical">
      <flexbox-item>
        <div class="flex-demo">
          <div>
            <div class="namebox">
            <div class="namemsg">
            <img class="touxiang" src="static/img/sd.png" alt="">
            <div class="Tname">
            <span class="name">{{sd_detail.Nick_name}}</span>
            <span class="time">{{sd_detail.Sd_time}}</span>  
            </div>  
            </div>
            </div>
            <p class="Title">
              {{sd_detail.Sd_text}}
            </p>
            <span class="Type">#树洞</span>

    <div class="Tclick">
    <!-- <div class="Tlike">
    <img slot="icon" src="static/img/pl.png" width="30">
    <p>聊聊</p>
    </div> -->
    <div class="Tmsg">
    <img slot="icon" src="static/img/msg.png" width="30">
    <p>{{formatLength(sd_detail.Pl_msg)==0? '评论':formatLength(sd_detail.Pl_msg)}}</p>
    </div>
    <!-- <div class="Tunlike" @click="Bao(Sdlist)">
    <img slot="icon" :src="Sdlist.Baoimg" width="30">
    <p>{{sd_detail.Sd_like}}</p>
    </div> -->
    </div>

            </div>
            </div>
      </flexbox-item>
<divider>评论</divider>
</flexbox>

<div id="PL" v-for="(Sdpl, index) in sd_detail.Pl_msg" :key="index">
<div class="topbox">
<div class="topuse">
<img class="topimg" slot="icon" src="static/img/sd.png">
<div class="nametime">
<span>{{Sdpl.Pl_nick}}</span>  
<span style="color:#999;font-size:12px;">{{Sdpl.Pl_time}}</span>  
</div>  
</div>
</div>
<div class="plbox">
<p style="font-size:14px;">{{Sdpl.Pl_text}}</p>
</div>
<divider>-</divider>  
</div>

<br><br><br>

<div class="schat">
  <div class="footer">
  <img src="static/img/图片.png" width="35" height="35" @click="isshow==false? isshow=true:isshow=false">
  <input class="Pinput" v-model="Msg" type="text" placeholder="看帖是喜欢，评论才是真爱">
  
  
  <img src="static/img/表情.png" width="35" height="35" @click="isshow==false? isshow=true:isshow=false">
  <button :class="Msg==''? 'Psendd':'Psend'" :disabled="Msg==''? true:false"  @click="addpl(Msg)">发送</button> 
  </div>
  
<div class="bqbox">
<div class="bq" v-show="isshow" v-for="(item,index) in bq" :key="index">
<span v-for="(i,index) in item" :key="index" @click="Msg+=i;isshow=false">{{i}}</span>
</div> 
</div>  

</div>    
  </div>
</template>
<script>
import { TransferDom } from 'vux'
export default {
    inject:['reload'],
    directives: {
    TransferDom
    },
    methods: {
    // Bao(b){
    //   if(b.Hug==false){b.Bao++,b.Hug=true,b.Baoimg='static/img/bao1.png'}
    //   else if(b.Hug==true){b.Bao--,b.Hug=false,b.Baoimg='static/img/bao.png'}
    // },
    formatLength(arr) {
          if(arr) {
              return arr.length
          }
      },
    getsd_detail(){
          var that = this;
          var id = this.$route.params.id;
          var sdid = this.$route.params.sdid;
          that.$http.get("http://localhost:3000/sd/sdd/" + id +'/'+ sdid)
          .then(
          (response)=>{
            that.sd_detail=response.data.msg.sdd;
            console.log(that.sd_detail);
          },
          (error)=>{
          console.log("err");
        });
      },
    addpl(Msg){
      this.$http.post("http://localhost:3000/sd/sdpl",
            {
              Sd_id:this.$route.params.sdid,
              Pl_id:this.$route.params.id,
              Nick_name:this.$store.state.wd.wdnick,
              Pl_text:Msg,
            },{emulateJSON: true})
            .then(
            (response)=>{
              if(response.data.msg.status=='ok'){
              this.reload()//重载
              this.$vux.toast.show({
              type: 'text',
              text: '评论成功',
              position: 'middle',
              time: '1000'
              })
              }else{
              this.$vux.toast.show({
              type: 'text',
              text: '评论失败',
              position: 'middle',
              time: '1000'
              })
              }
            },
            (error)=>{
            console.log(error);
            }
            );
    }
  },
  mounted(){
    this.getsd_detail();
    $('html,body').animate({scrollTop: '0px'}, 0);//置顶
  },
  data () {
    return {
      sd_detail:{},
      Sdpllist:[],
      Msg:'',
      bq:[
          ['😂', '😭', '😹', '🙏', '😁', '😃', '😄', '😅',
          '😆', '😇', '😉', '😊', '😋', '😌', '😍', '😘',
          '😚', '😜', '😝', '😎', '😏', '😶', '😐' ,'😒',
          '😳', '😞', '😠', '😡', '😔', '😣', '😖' ,'😫',
          '😩', '😤', '😨', '😰', '😢', '😥', '😵', '👷',
          '😲', '😷', '💤', '🙌', '👏', '👋', '👊', '👌',
          '💪', '👍', '👆', '👇', '👈', '👉', '💩', '😈',
          '👿', '👹', '👺', '💀', '👻', '👽', '😺', '😸',
          '😻', '😼', '😽', '🙀', '😿', '😾', '👄', '💂',
          '👅', '👂', '👃', '👀', '👤', '👶', '👦', '👧',
          '👨', '👩', '👱', '👴', '👵', '👲', '👳', '👮',
          ],
            ],
      isshow:false,
    }
  }
  
}
</script>

<style lang="less" >
@import '~vux/src/styles/1px.less';

.flex-demo {//帖子css
  width: 100%;
  // background-color: #f8f6f6;浅灰
  border-radius: 4px;
  background-clip: padding-box;

  display: flex;
  display: -webkit-flex;
  flex-direction: column;
}
.namebox{
  margin-top: 10px;
  display: flex;
  justify-content:space-between;
  align-items:center;
}
.namemsg{
  margin-left: 20px;
  display: flex;
  flex-direction: row;
  justify-content:flex-start;
  width: 70%;
}
.Tname{
  display: flex;
  flex-direction: column;
}
.touxiang{
    background-color: aliceblue;
    border-radius: 50%;
    height: 50px;
    width: 50px;
    margin-right: 20px;
}
.name{
  margin-bottom: 5px;
  width: 200px;
  color: rgb(59, 59, 59);
  font-size: 14px;
  white-space:nowrap; 
  text-overflow:ellipsis;
  overflow:hidden;
}
.time{
  color: rgb(88, 88, 88);
  font-size: 12px;
}
.gz{
  margin-right: 20px;
  white-space:nowrap; 
    background-color: white; 
    color: black; 
    border: 2px solid #008CBA;
    border-radius: 15px;
    font-size: 12px;
    padding: 5px 15px;

}
.Tclick{
  display: flex;
  align-items:center;
  justify-content:space-around;
  margin-bottom: 10px;
  margin-top: 10px;
}
.Tlike{
  display: flex;
  align-items:center;
  justify-content:space-around;
}
.Tunlike{
  display: flex;
  align-items:center;
  justify-content:space-around;
}

.Tmsg{
  display: flex;
  align-items:center;
  justify-content:space-around;
}
.Title{
margin: 20px;
}
.Timg{
  margin-left: 10%;
  margin-top: 10px;
  width: 80%;
}

.topbox{//评论css
  margin-left: 20px;  
  margin-right: 20px;
  display: flex;
  display: -webkit-flex;
  justify-content:space-between;
}
.topimg{ 
  width: 50px;
  height: 50px;
}
.topuse{
  display: flex;
  justify-content: flex-start;
}
.nametime{
  display: flex;
  flex-direction: column;
  justify-content: left;
}
.topclick{
  width: 30%;
  display: flex;
  align-items:center;
  justify-content:space-around;
}
.like{
  display: flex;
  align-items:center;
}
.unlike{
  display: flex;
  align-items:center;
}
.plbox{
  padding-left: 50px;
  padding-right: 10px;
}
.plimg{
  font-size: 10px;
}//

.schat{//底部输入
background-color:rgb(220, 220, 220);
width: 100%;
position:fixed;
bottom:0px;
left:0px;

display: flex;
flex-direction: column;
}
.footer{
display: flex;
justify-content: space-around;
align-items:center;
padding-left: 5px;
padding-right: 5px;
height: 50px;
}
.Pinput{
  width: 65%;
  height: 35px;
  border: none;
  outline:none;
  font-size: 18px;
  text-indent: 10px;
  border-radius: 15px;
}
.Pinput:focus{
  border: none;
  outline:none
}
.Psend{
  width: 50px;
  height: 30px;
  background-color: green;
  border: none;
  color: white;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 12px;
  border-radius: 5px;
}
.Psendd{
  width: 50px;
  height: 30px;
  background-color: green;
  border: none;
  color: white;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 12px;
  border-radius: 5px;
  opacity: 0.6;
  cursor: not-allowed;
}
.bqbox{
  display: flex;
  justify-content: center;
}
.bq{
  font-size: 30px;
  width: 80%;
  height: 120px;
  display: flex;
  flex-wrap: wrap;
  overflow-y: scroll;
}
.Type{
    margin-left: 20px;
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: 2px;
    padding-top: 2px;
    font-size: 12px;
    color: #008CBA;
    border: 2px solid #008CBA;
    border-radius: 5px;
}
</style>